From fcaa8335c31d2ab6682ea39b607f9fa80599e168 Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Thu, 18 Mar 2004 14:48:11 +0000 Subject: [PATCH] bitkeeper revision 1.809 (4059b6abq9zvnfmJ9cVcMhBo_lOhew) Many files: Scheduler updates. sched_ctl.h: Rename: xen/include/hypervisor-ifs/sched-ctl.h -> xen/include/hypervisor-ifs/sched_ctl.h --- .rootkeys | 2 +- tools/xc/lib/xc_atropos.c | 8 +-- tools/xc/lib/xc_bvtsched.c | 18 ++--- tools/xc/lib/xc_private.h | 2 +- tools/xc/lib/xc_rrobin.c | 3 +- tools/xc/py/Makefile | 2 +- tools/xenctl/Makefile | 2 +- tools/xenctl/lib/console_client.py | 3 + tools/xend/Makefile | 2 +- xen/common/dom0_ops.c | 2 +- xen/common/sched_rrobin.c | 4 +- xen/common/schedule.c | 70 ++++++++----------- xen/include/hypervisor-ifs/dom0_ops.h | 2 +- .../{sched-ctl.h => sched_ctl.h} | 23 +++--- 14 files changed, 65 insertions(+), 78 deletions(-) rename xen/include/hypervisor-ifs/{sched-ctl.h => sched_ctl.h} (69%) diff --git a/.rootkeys b/.rootkeys index d302f37329..e1a72ba503 100644 --- a/.rootkeys +++ b/.rootkeys @@ -501,7 +501,7 @@ 3ead095dE_VF-QA88rl_5cWYRWtRVQ xen/include/hypervisor-ifs/kbd.h 3ddb79c2oRPrzClk3zbTkRHlpumzKA xen/include/hypervisor-ifs/network.h 4051db79512nOCGweabrFWO2M2h5ng xen/include/hypervisor-ifs/physdev.h -40589968wmhPmV5-ENbBYmMjnedgKw xen/include/hypervisor-ifs/sched-ctl.h +40589968wmhPmV5-ENbBYmMjnedgKw xen/include/hypervisor-ifs/sched_ctl.h 404f3d2eR2Owk-ZcGOx9ULGHg3nrww xen/include/hypervisor-ifs/trace.h 3f0d22cbroqp_BkoDPwkfRJhaw1LiQ xen/include/hypervisor-ifs/vbd.h 3ddb79c4qbCoOFHrv9sCGshbWzBVlQ xen/include/scsi/scsi.h diff --git a/tools/xc/lib/xc_atropos.c b/tools/xc/lib/xc_atropos.c index b9ee719b0f..06ba01cf32 100644 --- a/tools/xc/lib/xc_atropos.c +++ b/tools/xc/lib/xc_atropos.c @@ -12,11 +12,12 @@ int xc_atropos_global_set(int xc_handle, unsigned long ctx_allow) { dom0_op_t op; + op.cmd = DOM0_SCHEDCTL; - op.u.schedctl.if_ver = SCHED_CTL_IF_VER; op.u.schedctl.sched_id = SCHED_BVT; op.u.schedctl.u.bvt.ctx_allow = ctx_allow; + return do_dom0_op(xc_handle, &op); } @@ -24,15 +25,12 @@ int xc_atropos_domain_set(int xc_handle, u64 domid, int xtratime) { dom0_op_t op; - op.cmd = DOM0_ADJUSTDOM; + op.cmd = DOM0_ADJUSTDOM; op.u.adjustdom.domain = (domid_t)domid; - op.u.adjustdom.if_ver = SCHED_CTL_IF_VER; op.u.adjustdom.sched_id = SCHED_ATROPOS; op.u.adjustdom.u.atropos.xtratime = xtratime; - printf("Doing dom0 op!\n"); - return do_dom0_op(xc_handle, &op); } diff --git a/tools/xc/lib/xc_bvtsched.c b/tools/xc/lib/xc_bvtsched.c index e38f9cf09e..428c2d6c32 100644 --- a/tools/xc/lib/xc_bvtsched.c +++ b/tools/xc/lib/xc_bvtsched.c @@ -12,10 +12,12 @@ int xc_bvtsched_global_set(int xc_handle, unsigned long ctx_allow) { dom0_op_t op; + op.cmd = DOM0_SCHEDCTL; op.u.schedctl.sched_id = SCHED_BVT; - op.u.schedctl.if_ver = SCHED_CTL_IF_VER; + op.u.schedctl.u.bvt.ctx_allow = ctx_allow; + return do_dom0_op(xc_handle, &op); } @@ -27,16 +29,16 @@ int xc_bvtsched_domain_set(int xc_handle, unsigned long warpu) { dom0_op_t op; - struct bvt_adjdom *adjptr = &op.u.adjustdom.u.bvt; + struct bvt_adjdom *bvtadj = &op.u.adjustdom.u.bvt; op.cmd = DOM0_ADJUSTDOM; - op.u.adjustdom.sched_id = SCHED_BVT; - op.u.adjustdom.if_ver = SCHED_CTL_IF_VER; op.u.adjustdom.domain = (domid_t)domid; + op.u.adjustdom.sched_id = SCHED_BVT; + + bvtadj->mcu_adv = mcuadv; + bvtadj->warp = warp; + bvtadj->warpl = warpl; + bvtadj->warpu = warpu; - adjptr->mcu_adv = mcuadv; - adjptr->warp = warp; - adjptr->warpl = warpl; - adjptr->warpu = warpu; return do_dom0_op(xc_handle, &op); } diff --git a/tools/xc/lib/xc_private.h b/tools/xc/lib/xc_private.h index 859d3a7740..8762790836 100644 --- a/tools/xc/lib/xc_private.h +++ b/tools/xc/lib/xc_private.h @@ -23,7 +23,7 @@ #include #include #include -#include +#include #define _PAGE_PRESENT 0x001 #define _PAGE_RW 0x002 diff --git a/tools/xc/lib/xc_rrobin.c b/tools/xc/lib/xc_rrobin.c index 4d986cee83..c915508050 100644 --- a/tools/xc/lib/xc_rrobin.c +++ b/tools/xc/lib/xc_rrobin.c @@ -11,10 +11,11 @@ int xc_rrobin_global_set(int xc_handle, u64 slice) { dom0_op_t op; + op.cmd = DOM0_SCHEDCTL; - op.u.schedctl.if_ver = SCHED_CTL_IF_VER; op.u.schedctl.sched_id = SCHED_RROBIN; op.u.schedctl.u.rrobin.slice = slice; + return do_dom0_op(xc_handle, &op); } diff --git a/tools/xc/py/Makefile b/tools/xc/py/Makefile index e3583f5dd8..6a4f34846d 100644 --- a/tools/xc/py/Makefile +++ b/tools/xc/py/Makefile @@ -4,7 +4,7 @@ all: install: all if [ "$(prefix)" = "" ]; then python setup.py install; \ - else python setup.py install --home="$(prefix)"; fi + else python setup.py install --root="$(prefix)"; fi clean: rm -rf build *.pyc *.pyo *.o *.a *~ diff --git a/tools/xenctl/Makefile b/tools/xenctl/Makefile index e3583f5dd8..6a4f34846d 100644 --- a/tools/xenctl/Makefile +++ b/tools/xenctl/Makefile @@ -4,7 +4,7 @@ all: install: all if [ "$(prefix)" = "" ]; then python setup.py install; \ - else python setup.py install --home="$(prefix)"; fi + else python setup.py install --root="$(prefix)"; fi clean: rm -rf build *.pyc *.pyo *.o *.a *~ diff --git a/tools/xenctl/lib/console_client.py b/tools/xenctl/lib/console_client.py index df15d6f1d3..84109dda96 100644 --- a/tools/xenctl/lib/console_client.py +++ b/tools/xenctl/lib/console_client.py @@ -72,4 +72,7 @@ def connect(host,port): __send_to_sock(sock) if __name__ == '__main__': + if len(sys.argv) != 3: + print sys.argv[0] + " " + sys.exit(1) connect(str(sys.argv[1]),int(sys.argv[2])) diff --git a/tools/xend/Makefile b/tools/xend/Makefile index 93c0cfe1f7..944620d5ec 100644 --- a/tools/xend/Makefile +++ b/tools/xend/Makefile @@ -4,7 +4,7 @@ all: install: all if [ "$(prefix)" = "" ]; then python setup.py install; \ - else python setup.py install --home="$(prefix)"; fi + else python setup.py install --root="$(prefix)"; fi mkdir -p $(prefix)/usr/sbin install -m0755 xend $(prefix)/usr/sbin diff --git a/xen/common/dom0_ops.c b/xen/common/dom0_ops.c index 1d69f35bf3..8ff3139f80 100644 --- a/xen/common/dom0_ops.c +++ b/xen/common/dom0_ops.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include extern unsigned int alloc_new_dom_mem(struct task_struct *, unsigned int); diff --git a/xen/common/sched_rrobin.c b/xen/common/sched_rrobin.c index ef4db60066..e5eb2ecd13 100644 --- a/xen/common/sched_rrobin.c +++ b/xen/common/sched_rrobin.c @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include @@ -43,7 +43,7 @@ static void rr_dump_settings() } struct scheduler sched_rrobin_def = { - .name = "Stupid Round Robin Scheduler", + .name = "Round-Robin Scheduler", .opt_name = "rrobin", .sched_id = SCHED_RROBIN, diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 054123077c..9e5973f4a1 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include /*#define WAKEUP_HISTO*/ @@ -40,8 +40,10 @@ #define TIME_SLOP (s32)MICROSECS(50) /* allow time to slip a bit */ -/* XXX MAW pull trace-related #defines out of here and into an auto-generated - * header file later on! */ +/* + * XXX Pull trace-related #defines out of here and into an auto-generated + * header file later on! + */ #define TRC_SCHED_DOM_ADD 0x00010000 #define TRC_SCHED_DOM_REM 0x00010001 #define TRC_SCHED_WAKE 0x00010002 @@ -66,26 +68,23 @@ static void t_timer_fn(unsigned long unused); static void dom_timer_fn(unsigned long data); static void fallback_timer_fn(unsigned long unused); -/* this is global for now so that private implementations can reach it */ +/* This is global for now so that private implementations can reach it. */ schedule_data_t schedule_data[NR_CPUS]; -/* XXX would be nice if the schedulers array could get populated - * automagically without having to hack the code in here */ +/* + * XXX It would be nice if the schedulers array could get populated + * automagically without having to hack the code in here. + */ extern struct scheduler sched_bvt_def, sched_rrobin_def; static struct scheduler *schedulers[] = { &sched_bvt_def, &sched_rrobin_def, NULL}; -/* scheduler ops for the current scheduler */ +/* Operations for the current scheduler. */ static struct scheduler ops; -/* for scheduler functions that return void */ -#define SCHED_FN_VOID(fn, ...) do { if ( ops.fn ) ops.fn(__VA_ARGS__); } \ - while (0) - -/* for scheduler functions that return a numeric value */ -#define SCHED_FN_RET(fn, ...) \ - (( ops.fn != NULL ) ? ops.fn( __VA_ARGS__ ) : 0 ) +#define SCHED_FN(fn, ...) \ + ((ops.fn != NULL) ? (ops.fn(__VA_ARGS__)) : (typeof(ops.fn(__VA_ARGS__)))0) spinlock_t schedule_lock[NR_CPUS] __cacheline_aligned; @@ -102,7 +101,7 @@ extern kmem_cache_t *task_struct_cachep; void free_task_struct(struct task_struct *p) { - SCHED_FN_VOID(free_task, p); + SCHED_FN(free_task, p); kmem_cache_free(task_struct_cachep, p); } @@ -120,7 +119,7 @@ struct task_struct *alloc_task_struct(void) memset(p, 0, sizeof(*p)); - if ( SCHED_FN_RET(alloc_task, p) < 0) + if ( SCHED_FN(alloc_task, p) < 0) { kmem_cache_free(task_struct_cachep, p); return NULL; @@ -134,7 +133,7 @@ struct task_struct *alloc_task_struct(void) */ void sched_add_domain(struct task_struct *p) { - p->state = TASK_STOPPED; + p->state = TASK_STOPPED; if( p->domain != IDLE_DOMAIN_ID ) { @@ -149,14 +148,11 @@ void sched_add_domain(struct task_struct *p) schedule_data[p->processor].idle = p; } - SCHED_FN_VOID(add_task, p); + SCHED_FN(add_task, p); TRACE_3D(TRC_SCHED_DOM_ADD, _HIGH32(p->domain), _LOW32(p->domain), p); } -/* XXX race condition here? we could both add and remove a domain at once, in - * theory. ick! */ -/* XXX is the task already removed from the runlist at this point? */ int sched_rem_domain(struct task_struct *p) { int x, y = p->state; @@ -166,7 +162,7 @@ int sched_rem_domain(struct task_struct *p) rem_ac_timer(&p->timer); - SCHED_FN_VOID(rem_task, p); + SCHED_FN(rem_task, p); TRACE_3D(TRC_SCHED_DOM_REM, _HIGH32(p->domain), _LOW32(p->domain), p); @@ -179,9 +175,9 @@ void init_idle_task(void) unsigned long flags; struct task_struct *p = current; - if ( SCHED_FN_RET (alloc_task, p) < 0) + if ( SCHED_FN (alloc_task, p) < 0) panic("Failed to allocate scheduler private data for idle task"); - SCHED_FN_VOID(add_task, p); + SCHED_FN(add_task, p); spin_lock_irqsave(&schedule_lock[p->processor], flags); p->has_cpu = 1; @@ -202,7 +198,7 @@ void __wake_up(struct task_struct *p) p->state = TASK_RUNNING; - SCHED_FN_VOID(wake_up, p); + SCHED_FN(wake_up, p); #ifdef WAKEUP_HISTO p->wokenup = NOW(); @@ -319,13 +315,10 @@ long sched_ctl(struct sched_ctl_cmd *cmd) { TRACE_0D(TRC_SCHED_CTL); - if ( cmd->if_ver != SCHED_CTL_IF_VER ) - return -EACCES; - if ( cmd->sched_id != ops.sched_id ) return -EINVAL; - return SCHED_FN_RET(control, cmd); + return SCHED_FN(control, cmd); } @@ -334,9 +327,6 @@ long sched_adjdom(struct sched_adjdom_cmd *cmd) { struct task_struct *p; - if ( cmd->if_ver != SCHED_CTL_IF_VER ) - return -EACCES; - if ( cmd->sched_id != ops.sched_id ) return -EINVAL; @@ -347,7 +337,7 @@ long sched_adjdom(struct sched_adjdom_cmd *cmd) TRACE_2D(TRC_SCHED_ADJDOM, _HIGH32(p->domain), _LOW32(p->domain)); - SCHED_FN_VOID(adjdom, p, cmd); + SCHED_FN(adjdom, p, cmd); put_task_struct(p); return 0; @@ -388,7 +378,7 @@ unsigned long __reschedule(struct task_struct *p) if ( schedule_data[cpu].s_timer.expires > min_time + TIME_SLOP ) mod_ac_timer(&schedule_data[cpu].s_timer, min_time); - return SCHED_FN_RET(reschedule, p); + return SCHED_FN(reschedule, p); } void reschedule(struct task_struct *p) @@ -436,7 +426,7 @@ asmlinkage void __enter_scheduler(void) if ( signal_pending(prev) ) prev->state = TASK_RUNNING; else - SCHED_FN_VOID(do_block, prev); + SCHED_FN(do_block, prev); } /* get policy-specific decision on scheduling... */ @@ -623,10 +613,10 @@ void __init scheduler_init(void) if ( ops.do_schedule == NULL) panic("Chosen scheduler has NULL do_schedule!"); - if ( SCHED_FN_RET(init_scheduler) < 0 ) + if ( SCHED_FN(init_scheduler) < 0 ) panic("Initialising scheduler failed!"); - SCHED_FN_VOID(add_task, &idle0_task); + SCHED_FN(add_task, &idle0_task); } /* @@ -666,7 +656,7 @@ static void dump_rqueue(struct list_head *queue, char *name) list_for_each (list, queue) { p = list_entry(list, struct task_struct, run_list); printk("%3d: %llu has=%c ", loop++, p->domain, p->has_cpu ? 'T':'F'); - SCHED_FN_VOID(dump_runq_el, p); + SCHED_FN(dump_runq_el, p); printk("c=0x%X%08X\n", (u32)(p->cpu_time>>32), (u32)p->cpu_time); printk(" l: %lx n: %lx p: %lx\n", (unsigned long)list, (unsigned long)list->next, @@ -682,12 +672,12 @@ void dump_runq(u_char key, void *dev_id, struct pt_regs *regs) int i; printk("Scheduler: %s (%s)\n", ops.name, ops.opt_name); - SCHED_FN_VOID(dump_settings); + SCHED_FN(dump_settings); printk("NOW=0x%08X%08X\n", (u32)(now>>32), (u32)now); for (i = 0; i < smp_num_cpus; i++) { spin_lock_irqsave(&schedule_lock[i], flags); printk("CPU[%02d] ", i); - SCHED_FN_VOID(dump_cpu_state,i); + SCHED_FN(dump_cpu_state,i); dump_rqueue(&schedule_data[i].runqueue, "rq"); spin_unlock_irqrestore(&schedule_lock[i], flags); } diff --git a/xen/include/hypervisor-ifs/dom0_ops.h b/xen/include/hypervisor-ifs/dom0_ops.h index d06a9f641a..8574f02531 100644 --- a/xen/include/hypervisor-ifs/dom0_ops.h +++ b/xen/include/hypervisor-ifs/dom0_ops.h @@ -11,7 +11,7 @@ #define __DOM0_OPS_H__ #include "hypervisor-if.h" -#include "sched-ctl.h" +#include "sched_ctl.h" /* * Make sure you increment the interface version whenever you modify this file! diff --git a/xen/include/hypervisor-ifs/sched-ctl.h b/xen/include/hypervisor-ifs/sched_ctl.h similarity index 69% rename from xen/include/hypervisor-ifs/sched-ctl.h rename to xen/include/hypervisor-ifs/sched_ctl.h index bb0449908a..bd9e9d082c 100644 --- a/xen/include/hypervisor-ifs/sched-ctl.h +++ b/xen/include/hypervisor-ifs/sched_ctl.h @@ -4,26 +4,20 @@ * Mark Williamson, (C) 2004 Intel Research Cambridge */ -#ifndef _SCHED_CTL_H_ -#define _SCHED_CTL_H_ +#ifndef __SCHED_CTL_H__ +#define __SCHED_CTL_H__ -/** - * When this file is changed, increment the version number. This ensures that - * tools will refuse to work (rather than causing a crash) when they're - * out-of-sync with the Xen version number. - */ -#define SCHED_CTL_IF_VER 0x0001 - -/* scheduler types */ +/* Scheduler types. */ #define SCHED_BVT 0 #define SCHED_ATROPOS 1 #define SCHED_RROBIN 2 -/* generic scheduler control command - union of all scheduler control - * command structures */ +/* + * Generic scheduler control command: union of all scheduler control command + * structures. + */ struct sched_ctl_cmd { - unsigned int if_ver; unsigned int sched_id; union @@ -44,7 +38,6 @@ struct sched_ctl_cmd struct sched_adjdom_cmd { - unsigned int if_ver; unsigned int sched_id; domid_t domain; @@ -65,4 +58,4 @@ struct sched_adjdom_cmd } u; }; -#endif /* _SCHED_CTL_H_ */ +#endif /* __SCHED_CTL_H__ */ -- 2.30.2